// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";
import App from "./App";
import store from './store'
import router from "./router";
import { LoadingPlugin, ToastPlugin } from "vux";
import { getToken } from "@/api/auth";
import md5 from "js-md5";
import { ConfirmPlugin } from 'vux'
import './assets/css/public.css' /*引入公共样式*/
import './assets/styles/global.css'
import VueBarcode from "vue-barcode";
import moment from "moment";
import { AlertPlugin } from 'vux'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
//TODO 开启console 调试模式
// import VConsole from 'vconsole';
// const vConsole = new VConsole();

Vue.use(AlertPlugin)
Vue.prototype.$moment = moment
Vue.component('barcode', VueBarcode);
Vue.use(ConfirmPlugin)
Vue.prototype.$md5 = md5;
Vue.use(ToastPlugin, { position: "middle", type: "text" });
Vue.use(LoadingPlugin);
Vue.use(ElementUI);
Vue.config.productionTip = false;
Vue.config.ignoredElements = ['wx-open-launch-weapp'];
/* eslint-disable no-new */


const defaultTitle = '医大口腔医院'
router.beforeEach((to, from, next) => {
    console.log(to)
    document.title = to.meta.title ? to.meta.title : defaultTitle
    if (
        to.meta.show
    ) {
        next();
    } else {
        let token = getToken() || "";
        // console.log(token)
        if (token === 'null' || token === '') {
            next('/');
        } else {
            next();
        }
    }
})
new Vue({
    el: "#app",
    router,
    store,
    components: { App },
    template: "<App/>"
});
